package com.cloud.service.impl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cloud.domian.Order;
import com.cloud.feign.ItemFeignService;
import com.cloud.mapper.OrderMapper;
import com.cloud.service.IOrderService;
import io.seata.core.exception.TransactionException;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * @Description: 订单表
 * @Author: jeecg-boot
 * @Date:   2022-05-13
 * @Version: V1.0
 */
@Service(value = "OrderServiceImpl2")
@Slf4j
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {

    @Resource
    private ItemFeignService itemFeignService;

    @Override
    @GlobalTransactional(rollbackFor = Exception.class)
    @Trace
    @Tag(key = "addOrder2",value = "returnedObj")
    @Tag(key = "addOrder2",value = "arg[0]")
    @Tag(key = "addOrder2",value = "arg[1]")
    public String createOrder(Long productId, Long productSpecs) throws TransactionException {
        Order order = new Order();
        order.setOrderNumber("HX123456789");
        baseMapper.insert(order);
        String s = itemFeignService.decStock2();
        //int a = 1/0;

        System.out.println();
        return s;
    }
}
